package com.ytsakura.blog.dao;

import com.ytsakura.blog.pojo.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;


@Repository
public interface UserRepository extends JpaRepository<User,Long>{

    User findByUsernameAndPassword(String username,String password);

    User findByUsername(String username);

    @Transactional
    @Modifying
    @Query("update User u set u.avatar =?1 where  u.id =?2")
    void updateAvatar(String avatar,Long id);
}
